/////////////////////////////////////////////////////////////////////////////
// This file is part of the "Java-DAP" project, a Java implementation
// of the OPeNDAP Data Access Protocol.
//
// Copyright (c) 2007 OPeNDAP, Inc.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
/////////////////////////////////////////////////////////////////////////////
using System;
using NDODS.DAP.Primitives;

namespace NDODS.DAP.BaseTypes
{
	
	/// <summary> Holds a OPeNDAP <code>Float64</code> value.
	/// 
	/// </summary>
	/// <author>  jehamby
	/// </author>
	/// <version>  $Revision: 15901 $
	/// </version>
	/// <seealso cref="BaseType">
	/// </seealso>
	[Serializable]
	public class DFloat64:BaseType, IClientIO
	{
		//UPGRADE_NOTE: Respective javadoc comments were merged.  It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'"
		/// <summary> Get the current value as a double.
		/// 
		/// </summary>
		/// <returns> the current value.
		/// </returns>
		/// <summary> Set the current value.
		/// 
		/// </summary>
		/// <param name="newVal">the new value.
		/// </param>
		virtual public double Value
		{
			get
			{
				return val;
			}
			
			set
			{
				val = value;
			}
			
		}
		/// <summary> Returns the OPeNDAP type name of the class instance as a <code>String</code>.
		/// 
		/// </summary>
		/// <returns> the OPeNDAP type name of the class instance as a <code>String</code>.
		/// </returns>
		override public System.String TypeName
		{
			get
			{
				return "Float64";
			}
			
		}
		/// <summary> Constructs a new <code>DFloat64</code>.</summary>
		public DFloat64():base()
		{
		}
		
		/// <summary> Constructs a new <code>DFloat64</code> with name <code>n</code>.
		/// 
		/// </summary>
		/// <param name="n">the name of the variable.
		/// </param>
		public DFloat64(System.String n):base(n)
		{
		}
		
		/// <summary> The value of this <code>DFloat64</code>.</summary>
		private double val;
		
		/// <summary> Constructs a new <code>Float64PrimitiveVector</code>.
		/// 
		/// </summary>
		/// <returns> a new <code>Float64PrimitiveVector</code>.
		/// </returns>
		public override PrimitiveVector NewPrimitiveVector()
		{
			return new Float64PrimitiveVector(this);
		}
		
		
		/// <summary> Prints the value of the variable, with its declaration.  This
		/// function is primarily intended for debugging OPeNDAP applications and
		/// text-based clients such as geturl.
		/// 
		/// </summary>
		/// <param name="os">          the <code>StreamWriter</code> on which to Print the value.
		/// </param>
		/// <param name="space">       this value is passed to the <code>PrintDeclaration</code> method,
		/// and controls the leading spaces of the output.
		/// </param>
		/// <param name="Print_decl_p">a bool value controlling whether the
		/// variable declaration is printed as well as the value.
		/// </param>
		/// <seealso cref="BaseType.printVal(StreamWriter, String, bool)">
		/// </seealso>
		public override void  PrintValue(System.IO.StreamWriter os, System.String space, bool print_decl_p)
		{
			if (print_decl_p)
			{
				PrintDeclaration(os, space, false);
				//UPGRADE_TODO: Method 'java.io.StreamWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioStreamWriterprintln_javalangString'"
				os.WriteLine(" = " + val + ";");
			}
			else
				os.Write(val);
		}
		
		/// <summary> Reads data from a <code>DataInputStream</code>. This method is only used
		/// on the client side of the OPeNDAP client/server connection.
		/// 
		/// </summary>
		/// <param name="source">  a <code>DataInputStream</code> to Read from.
		/// </param>
		/// <param name="sv">      the <code>ServerVersion</code> returned by the server.
		/// </param>
		/// <param name="statusUI">the <code>StatusUI</code> object to use for GUI updates
		/// and user cancellation notification (may be null).
		/// </param>
		/// <throws>  EOFException if EOF is found before the variable is completely </throws>
		/// <summary>                      deserialized.
		/// </summary>
		/// <throws>  IOException  thrown on any other InputStream exception. </throws>
		/// <seealso cref="ClientIO.deserialize(DataInputStream, ServerVersion, StatusUI)">
		/// </seealso>
		//UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
		//UPGRADE_NOTE: Synchronized keyword was removed from method 'Deserialize'. Lock expression was added. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1027'"
		public virtual void  Deserialize(System.IO.BinaryReader source, ServerVersion sv, IStatusUI statusUI)
		{
			lock (this)
			{
				val = source.ReadDouble();
				if (statusUI != null)
					statusUI.IncrementByteCount(8);
			}
		}
		
		/// <summary> Writes data to a <code>DataOutputStream</code>. This method is used
		/// primarily by GUI clients which need to download OPeNDAP data, manipulate
		/// it, and then re-save it as a binary file.
		/// 
		/// </summary>
		/// <param name="sink">a <code>DataOutputStream</code> to write to.
		/// </param>
		/// <throws>  IOException thrown on any <code>OutputStream</code> </throws>
		/// <summary>                     exception.
		/// </summary>
		//UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
		public virtual void  Externalize(System.IO.BinaryWriter sink)
		{
			sink.Write(val);
		}
		//UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
		override public System.Object Clone()
		{
			return null;
		}
	}
}